<template>
  <j-modal
    :title="title"
    :width="width"
    :visible="visible"
    :maskClosable="false"
    @cancel="handleCancel">
    <a-spin :spinning="confirmLoading">
      <material-detail-list
        :materialId="materialId"
        :disabled="true"
        :showOperator="false"
        :tableHeight="400"
      />
    </a-spin>
    <template slot="footer">
      <a-button @click="handleCancel">关闭</a-button>
    </template>
  </j-modal>
</template>

<script>
  import MaterialDetailList from './MaterialDetailList'
  import JModal from '@/components/jeecg/JModal/JModal'

  export default {
    name: 'MaterialDetailModal',
    components: {
      MaterialDetailList,
      JModal
    },
    data() {
      return {
        title: '物料组成明细',
        width: 900,
        visible: false,
        confirmLoading: false,
        materialId: ''
      }
    },
    methods: {
      show(materialId, materialName) {
        this.visible = true
        this.materialId = materialId
        if (materialName) {
          this.title = `${materialName} - 物料组成明细`
        } else {
          this.title = '物料组成明细'
        }
      },
      handleCancel() {
        this.visible = false
        this.materialId = ''
      }
    }
  }
</script> 